package server.util;

import java.util.HashMap;

public class SessionUtil {
    public  HashMap<String, String> sessionToUserName;

    public SessionUtil(){
        sessionToUserName = new HashMap<String, String>();
    }
    public  String getSession(String userName) throws Exception {
        return MD5Util.encryMD5(userName);
    }
    public void insertSession(String session, String userName){
        sessionToUserName.put(session, userName);
    }
    public  void removeSession(String session){
        sessionToUserName.remove(session);
    }
    public  boolean isLogin(String session){
        return sessionToUserName.containsKey(session);
    }
    public  String getLoginUserName(String session){
        if(!sessionToUserName.containsKey(session)){
            return null;
        }
        return sessionToUserName.get(session);
    }
}
